Programming Arduino by Simon Monk

Programming Arduino by Simon Monk

Author:Simon Monk
Language: eng
Format: epub
Publisher: McGraw Hill LLC
Published: 2023-12-15T00:00:00+00:00


The flashSequence Function

We have assumed a function called flashSequence and made use of it, but now you need to write it. We have planned for it to take a string containing a series of dashes and dots and to make the necessary flashes with the correct timings.

Thinking about the algorithm for doing this, you can break it into the following steps:

For each element of the string of dashes and dots (such as .-.-):

Flash that dot or dash.

Using the concept of programming by intention, let’s keep the function as simple as that.

The Morse codes are not the same length for all letters, so you need to loop around the string until you encounter the end marker, . You also need a counter variable called i that starts at 0 and is incremented as the processing looks at each dot and dash:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.